package com.uml.umlwork.vo.teacher;


import com.uml.umlwork.entity.Teacher;
import com.uml.umlwork.entity.enumeration.GenderEnum;
import com.uml.umlwork.entity.enumeration.TeacherTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Optional;

/**
 * @author siki
 */
@ApiModel("教师信息VO")
@Getter
@Setter
@NoArgsConstructor
public class TeacherInfoVO {
    @ApiModelProperty("id")
    String id;

    @ApiModelProperty("用户名")
    String username;

    @ApiModelProperty("姓名")
    private String name;

    @ApiModelProperty("联系方式")
    private String phone;

    @ApiModelProperty("年龄")
    private Integer age;

    @ApiModelProperty("性别")
    private String gender;

    @ApiModelProperty("邮箱")
    private String email;

    @ApiModelProperty("教师类型")
    private String teacherType;

    public TeacherInfoVO(Teacher teacher) {
        this.id = teacher.getUserId();
        this.age = teacher.getAge();
        this.gender = Optional.ofNullable(teacher.getGender()).map(GenderEnum::getName)
                .orElse(GenderEnum.MAN.getName());
        this.email = teacher.getEmail();
        this.teacherType = Optional.ofNullable(teacher.getTeacherType())
                .map(TeacherTypeEnum::getName).orElse(TeacherTypeEnum.NOT.getName());
    }
}
